package com.wink.charity;

import java.util.Date;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.google.gson.Gson;
//import com.wink.common.Identity;
import com.wink.service.CommunityServicesImpl;

@XmlRootElement(name = "charity")
@XmlAccessorType(XmlAccessType.FIELD)
public class Charity {	

	@XmlElement(name = "name")
	private String name;	
	
	@XmlElement(name = "description")
	private String description;
	
	@XmlElement(name = "amount")
	private String amount;
	
	@XmlElement(name = "communityID")
	private String communityID;				
	
	
	@XmlElement(name = "createdBy")
	private String createdBy;	
	
	@XmlElement(name = "charityID")
	private String charityID;	
	
	private String response;
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
		
	public String getAmount() {
		return amount;
	}

	public void setAmount(String amount) {
		this.amount = amount;
	}
	
	public String getCommunityID() {
		return communityID;
	}

	public void setCommunityID(String communityID) {
		this.communityID = communityID;
	}
	
	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public String getCharityID() {
		return charityID;
	}

	public void setCharityID(String charityID) {
		this.charityID = charityID;
	}
	
	public String toString() {
		StringBuffer sf = new StringBuffer();
		
		sf.append("<name> " + name);
		sf.append("<description> " + description);		
		sf.append("<amount> " + amount);
		sf.append("<community> " + communityID);
		sf.append("<createdBy> " + createdBy);
		sf.append("<charityID> " +  charityID);
				
		return sf.toString();
	}
	
	public static String toJson(Charity charity) {
		Gson gson = new Gson();
		String json = gson.toJson(charity, Charity.class);
		System.out.println("---> Chairty: tojson  " + json);
		
		Charity retCh = gson.fromJson(json, Charity.class);
		return json;
	}
	
	public static Charity fromJson(String json) {
		Gson gson = new Gson();
		Charity retCh = gson.fromJson(json, Charity.class);
		System.out.println("---> Chairty: fromJson  " + retCh.toString());
		return retCh;
	}
	
	

	public String getResponse() {
		return response;
	}

	public void setResponse(String response) {
		this.response = response;
	}
	
}


